package day04_api_code.com.itheima.d1_stringbuilder;

public class Demo3_StringBuilder {
    public static void main(String[] args) {
        int[] arr = {11, 22, 33, 44};
        System.out.println("getArrayData(arr) = " + getArrayData(arr));
    }

    public static String getArrayData(int[] arr){
        if (arr == null){
            return null;
        }
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {
            int data = arr[i];
            sb.append( data).append(i == arr.length - 1 ? "" : ",");
        }
        sb.append("]");
        return sb.toString();
    }
}
